﻿using Enyim.Caching;
using Ayatta.Contract;
using System.Web.Mvc;
using Ayatta.Contract.Domain;
using Web.Base.Extensions;
using Web.Manage.Controllers;
using Web.Manage.Areas.Game.Models;

namespace Web.Manage.Areas.Game.Controllers
{
    public class HomeController : AdminBaseController
    {

        public HomeController(ILogService logService, IBaseService baseService, IExtraService extraService, IStoreService storeService, IOrderService orderService, IGameService gameService, IAuctionService auctionService, IPassportService passportService, IPaymentService paymentService, IMemcachedClient memcachedClient)
            : base(logService, baseService, extraService, storeService, orderService, gameService, auctionService, passportService, paymentService, memcachedClient)
        {
        }

        public ActionResult Index(int page = 1, int size = 2, string name = null, GameType? type = null, GameCategory? category = null, bool? status = null, bool? isHot = null, bool? isRefined = null)
        {
            var model = new GameControllerModel.Index();
            model.Name = name;
            model.Status = status;
            model.IsHot = isHot;
            model.IsRefined = isRefined;
            model.Games = GameService.GetPagedGames(page, size, name, type, category, status, isHot, isRefined).ToPagedList(page, size);
            return PartialView(model);
        }

        public ActionResult Detail(int param)
        {
            var model = GameService.GetGame(param);
            return PartialView(model);
        }

        public ActionResult Servers(int param)
        {
            var model = new GameControllerModel.Servers();
            model.Game = GameService.GetGame(param);
            model.GameServers = GameService.GetGameServers(param);
            return PartialView(model);
        }
    }
}
